/*******************
Input merchant-level data
Period: March-December 2004
*******************/

clear
clear matrix
clear mata

set more off

cd "Write the path of data folder"

use merchant.dta, clear

format shop %17.0g


label variable shop_transact "Total Transaction Quantity"

label variable shop_value "Total Transaction Value"

label variable shop_fee "Total Merchant Fee"


gen shop_rate = shop_fee/shop_value 
label variable shop_rate "Average Merchant Fee"

gen shop_avgvalue = shop_value/shop_transact
label variable shop_avgvalue "Average Transaction Value"


keep shop shop_transact shop_value shop_fee shop_rate shop_avgvalue

drop if shop_transact == . & shop_value == . &  shop_fee == . &  shop_rate == . &  shop_avgvalue == .  


/*******************
Convert the identifier to string format
Extract code 4-7 for area; 8-11 for industry
*******************/

gen code_s = string(shop,"%17.0g")


gen areacode_s = substr(code_s,-12,4)

gen areacode = real(areacode_s)

drop areacode_s

drop if areacode < 4400 | areacode > 4499

drop if areacode == 4400


gen code4_s = substr(code_s,-8,4)

sort code4_s code_s


/*******************
Define 4 and 87 groups
Assign fraud risk for 87 groups
********************/

do REStat_Define_groups


/*******************
Assign interchange fee and transfer fee
********************/

gen IFee = 0.014 if group5 == 1

replace IFee = 0.007 if group5 == 2

replace IFee = 0.007 if group5 == 3

replace IFee = 0.0035 if group5 == 4

replace IFee = 0 if group5 == 5


gen TFee = 0.002 if group5 == 1

replace TFee = 0.001 if group5 == 2

replace TFee = 0.001 if group5 == 3

replace TFee = 0.0005 if group5 == 4

replace TFee = 0 if group5 == 5


gen ITFee = IFee + TFee

gen shop_AFee = shop_rate - ITFee
label variable shop_AFee "Average Acquirer Fee"


/*******************
Match area data
********************/

sort areacode

merge areacode using area2004.dta

drop if _merge != 3

drop _merge


/*******************
Compute group measures
Imperfect match from MCC to merchant data

Recall: Opincome and Opcost are in Yuan
The other industry data is in 10000 Yuan
********************/

sort group87

merge group87 using industry2005.dta

drop if _merge != 3

drop _merge


/*******************
Count the number of shop in each industry 
Drop the industry with #shop < 4
********************/

gsort group87 -shop_value

by group87: egen group_transact = sum(shop_transact)

gen group_margin = (opincome-opcost)/opincome

gen group_LK = employee/totalasset 


gen one = 1

by group87: egen group_nshop = sum(one)

drop one

drop if group_nshop < 4


/*******************
Define varlables for regression
********************/

gen gdppc_1000 = GDPPC/1000

gen WageEmployed_1000 = WageEmployed/1000

gen napopratio = NAPopulation/Population

gen FIpc10000 = FI/Population 


/*******************
City FE
********************/

gen Chaozhou = 1 if Area=="Chaozhou"
replace Chaozhou = 0 if Chaozhou == .

gen Dongguan = 1 if Area=="Dongguan"
replace Dongguan = 0 if Dongguan == .

gen Foshan = 1 if Area=="Foshan"
replace Foshan = 0 if Foshan == .

gen Guangzhou = 1 if Area=="Guangzhou"
replace Guangzhou = 0 if Guangzhou == .

gen Heyuan = 1 if Area=="Heyuan"
replace Heyuan = 0 if Heyuan == .

gen Huizhou = 1 if Area=="Huizhou"
replace Huizhou = 0 if Huizhou == .

gen Jiangmen = 1 if Area=="Jiangmen"
replace Jiangmen = 0 if Jiangmen == .

gen Jieyang = 1 if Area=="Jieyang"
replace Jieyang = 0 if Jieyang == .

gen Maoming = 1 if Area=="Maoming"
replace Maoming = 0 if Maoming == .

gen Meizhou = 1 if Area=="Meizhou"
replace Meizhou = 0 if Meizhou == .

gen Qingyuan = 1 if Area=="Qingyuan"
replace Qingyuan = 0 if Qingyuan == .

gen Shanwei = 1 if Area=="Shanwei"
replace Shanwei = 0 if Shanwei == .

gen Shantou = 1 if Area=="Shantou"
replace Shantou = 0 if Shantou == .

gen Shaoguan = 1 if Area=="Shaoguan"
replace Shaoguan = 0 if Shaoguan == .

gen Yangjiang = 1 if Area=="Yangjiang"
replace Yangjiang = 0 if Yangjiang == .

gen Yunfu = 1 if Area=="Yunfu"
replace Yunfu = 0 if Yunfu == .

gen Zhanjiang = 1 if Area=="Zhanjiang"
replace Zhanjiang = 0 if Zhanjiang == .

gen Zhaoqing = 1 if Area=="Zhaoqing"
replace Zhaoqing = 0 if Zhaoqing == .

gen Zhongshan = 1 if Area=="Zhongshan"
replace Zhongshan = 0 if Zhongshan == .

gen Zhuhai = 1 if Area=="Zhuhai"
replace Zhuhai = 0 if Zhuhai == .


/*******************
Generate new group index
********************/

sort group87

egen temp = seq() if group87!=group87[_n-1]

by group87: egen group87s = mean(temp)

drop temp


/*******************
Generate IVs
1. The other shops in the same industry-area
2. The other shops in the same industry
********************/

sort group87s areacode

gen shop_transactshare = shop_transact/group_transact


by group87s areacode: egen temp_num = sum(shop_transactshare*shop_avgvalue)

by group87s areacode: egen temp_dem = sum(shop_transactshare)

gen rshop_VPT_T1 = (temp_num-shop_transactshare*shop_avgvalue)/(temp_dem-shop_transactshare)

drop temp_num temp_dem


by group87s: egen temp_num = sum(shop_transactshare*shop_avgvalue)

gen rshop_VPT_T2 = (temp_num-shop_transactshare*shop_avgvalue)/(1-shop_transactshare)

drop temp_num


/*******************
Working sample
Group5=3 loses a lot of data if shop_AFee > 0
  because of the upper limit for Apartment, Vehicle and Motor Home
Also, do not find wholesales industries with upper limit
********************/

drop if shop_AFee <= 0 

drop if group5 == 3

drop if rshop_VPT_T1 == .

* There are 68 observations with AFee <= 0.0000238, i.e. 0.00238%
* For 0.5% fee, AFee is about 0.05%; 
drop if shop_AFee < 0.0009 


/***********************
Table 2: Descriptive Statistics (except the last three columns) 
***********************/

sort group87s
su shop_rate shop_AFee, d

su shop_avgvalue, d

su group_margin group_LK, d

sort areacode
su WageEmployed_1000 gdppc_1000 napopratio, d


/***********************
Table 2: The last three columns
***********************/

egen shop_AFee_60 = pctile(shop_AFee), p(60) 

egen shop_AFee_40 = pctile(shop_AFee), p(40) 


gen treated = 0 if shop_AFee>=shop_AFee_60

replace treated = 1 if shop_AFee<=shop_AFee_40

local xvar "shop_rate shop_AFee shop_avgvalue group_margin group_LK WageEmployed_1000 gdppc_1000 napopratio"

foreach x of local xvar {
  display "`x'"
  ttest `x', by(treated) unequal
}


/***********************
Table 3
***********************/

reg shop_AFee group_margin i.group5, robust

reg shop_AFee group_margin group_LK i.group5, robust

reg shop_AFee group_margin group_LK WageEmployed_1000 i.group5, robust

reg shop_AFee group_margin group_LK gdppc_1000 i.group5, robust

reg shop_AFee group_margin group_LK napopratio i.group5, robust

reg shop_AFee group_margin group_LK i.areacode i.group5, robust

gen shop_avgvalue1000 = shop_avgvalue/1000

reg shop_AFee group_margin group_LK shop_avgvalue1000 i.areacode i.group5, robust


/***********************
Table 4
***********************/

tab group87 if group5 == 1
tab group87 if group5 == 2
tab group87 if group5 == 4
tab group87 if group5 == 5

su shop_AFee if group87 == 58
su shop_AFee if group87 == 37
su shop_AFee if group87 == 24
su shop_AFee if group87 == 79

su shop_AFee shop_avgvalue group_margin group_LK Wage gdppc napopratio if group5 == 1
su shop_AFee shop_avgvalue group_margin group_LK Wage gdppc napopratio if group5 == 2
su shop_AFee shop_avgvalue group_margin group_LK Wage gdppc napopratio if group5 == 4
su shop_AFee shop_avgvalue group_margin group_LK Wage gdppc napopratio if group5 == 5


/***********************
Variable construction
***********************/

gen Cater = 1 if group5 == 1
replace Cater = 0 if Cater ==.

gen Wel_Pub = 1 if group5 == 4 | group5 == 5
replace Wel_Pub = 0 if Wel_Pub ==.


gen VPT = shop_avgvalue

gen VPT_AFee = shop_avgvalue*shop_AFee

gen VPT_ITFee = shop_avgvalue*ITFee

gen VPT_Margin = VPT*group_margin

gen VPT_LK = VPT*group_LK


gen VPT_Cater = shop_avgvalue*Cater

gen VPT_Wel_Pub = shop_avgvalue*Wel_Pub


gen VPT_Chaozhou = VPT*Chaozhou 
gen VPT_Dongguan = VPT*Dongguan
gen VPT_Foshan = VPT*Foshan 
gen VPT_Guangzhou = VPT*Guangzhou 
gen VPT_Heyuan = VPT*Heyuan 
gen VPT_Huizhou = VPT*Huizhou 
gen VPT_Jiangmen = VPT*Jiangmen 
gen VPT_Jieyang = VPT*Jieyang 
gen VPT_Maoming = VPT*Maoming 
gen VPT_Meizhou = VPT*Meizhou
gen VPT_Qingyuan = VPT*Qingyuan 
gen VPT_Shantou = VPT*Shantou
gen VPT_Shanwei = VPT*Shanwei
gen VPT_Shaoguan = VPT*Shaoguan
gen VPT_Yangjiang = VPT*Yangjiang
gen VPT_Yunfu = VPT*Yunfu
gen VPT_Zhanjiang = VPT*Zhanjiang
gen VPT_Zhaoqing = VPT*Zhaoqing
gen VPT_Zhongshan = VPT*Zhongshan
gen VPT_Zhuhai = VPT*Zhuhai


/***********************
IV construction
***********************/

gen rVPT_ITFee = rshop_VPT_T1*ITFee

gen rVPT_Margin = rshop_VPT_T1*group_margin

gen rVPT_LK = rshop_VPT_T1*group_LK


gen rVPT_Cater = rshop_VPT_T1*Cater

gen rVPT_Wel_Pub = rshop_VPT_T1*Wel_Pub


gen rVPT_Chaozhou = rshop_VPT_T1*Chaozhou 
gen rVPT_Dongguan = rshop_VPT_T1*Dongguan
gen rVPT_Foshan = rshop_VPT_T1*Foshan 
gen rVPT_Guangzhou = rshop_VPT_T1*Guangzhou 
gen rVPT_Heyuan = rshop_VPT_T1*Heyuan 
gen rVPT_Huizhou = rshop_VPT_T1*Huizhou 
gen rVPT_Jiangmen = rshop_VPT_T1*Jiangmen 
gen rVPT_Jieyang = rshop_VPT_T1*Jieyang 
gen rVPT_Maoming = rshop_VPT_T1*Maoming 
gen rVPT_Meizhou = rshop_VPT_T1*Meizhou
gen rVPT_Qingyuan = rshop_VPT_T1*Qingyuan 
gen rVPT_Shantou = rshop_VPT_T1*Shantou
gen rVPT_Shanwei = rshop_VPT_T1*Shanwei
gen rVPT_Shaoguan = rshop_VPT_T1*Shaoguan
gen rVPT_Yangjiang = rshop_VPT_T1*Yangjiang
gen rVPT_Yunfu = rshop_VPT_T1*Yunfu
gen rVPT_Zhanjiang = rshop_VPT_T1*Zhanjiang
gen rVPT_Zhaoqing = rshop_VPT_T1*Zhaoqing
gen rVPT_Zhongshan = rshop_VPT_T1*Zhongshan
gen rVPT_Zhuhai = rshop_VPT_T1*Zhuhai


/***********************
Table 5: Model with City FEs
24 Parameters of surplus: Margin, LK, 2 Group FE, 20 City FE 
3 Parameters of bargain: LK, 2 Group FE 
1 Parameter of cost

24 Moments of surplus: Margin x rVPT, LK x rVPT, 2 Group FE x rVPT, 20 City FE x rVPT
3 Moments of bargain: LK, 2 Group FE
2 Moments of cost: Constant, FIpc10000

One extra moment  
***********************/

* Column 1

gmm ( VPT_AFee*(1+exp({b1}*Cater+{b45}*Wel_Pub)) - {b_Cost}*exp({b1}*Cater+{b45}*Wel_Pub) + VPT_ITFee ///
- {AM_Margin}*VPT_Margin - {AM1}*VPT_Cater - {AM45}*VPT_Wel_Pub - ({AMr:VPT_Chaozhou VPT_Dongguan VPT_Foshan VPT_Guangzhou VPT_Heyuan VPT_Huizhou VPT_Jiangmen VPT_Jieyang VPT_Maoming VPT_Meizhou ///
VPT_Qingyuan VPT_Shantou VPT_Shanwei VPT_Shaoguan VPT_Yangjiang VPT_Yunfu VPT_Zhanjiang VPT_Zhaoqing VPT_Zhongshan VPT_Zhuhai}) ), ///
instruments(FIpc10000 rVPT_Margin rVPT_Cater rVPT_Wel_Pub Cater Wel_Pub ///
rVPT_Chaozhou rVPT_Dongguan rVPT_Foshan rVPT_Guangzhou rVPT_Heyuan rVPT_Huizhou rVPT_Jiangmen rVPT_Jieyang rVPT_Maoming rVPT_Meizhou ///
rVPT_Qingyuan rVPT_Shantou rVPT_Shanwei rVPT_Shaoguan rVPT_Yangjiang rVPT_Yunfu rVPT_Zhanjiang rVPT_Zhaoqing rVPT_Zhongshan rVPT_Zhuhai) conv_maxiter(400) from(b1 3 b45 -2 b_Cost 3)

estat overid

* Column 2

gmm ( VPT_AFee*(1+exp({b_LK}*group_LK+{b1}*Cater+{b45}*Wel_Pub)) - {b_Cost}*exp({b_LK}*group_LK+{b1}*Cater+{b45}*Wel_Pub) + VPT_ITFee ///
- {AM_Margin}*VPT_Margin - {AM_LK}*VPT_LK  - {AM1}*VPT_Cater - {AM45}*VPT_Wel_Pub - ({AMr:VPT_Chaozhou VPT_Dongguan VPT_Foshan VPT_Guangzhou VPT_Heyuan VPT_Huizhou VPT_Jiangmen VPT_Jieyang VPT_Maoming VPT_Meizhou ///
VPT_Qingyuan VPT_Shantou VPT_Shanwei VPT_Shaoguan VPT_Yangjiang VPT_Yunfu VPT_Zhanjiang VPT_Zhaoqing VPT_Zhongshan VPT_Zhuhai}) ), ///
instruments(FIpc10000 rVPT_Margin rVPT_LK rVPT_Cater rVPT_Wel_Pub group_LK Cater Wel_Pub ///
rVPT_Chaozhou rVPT_Dongguan rVPT_Foshan rVPT_Guangzhou rVPT_Heyuan rVPT_Huizhou rVPT_Jiangmen rVPT_Jieyang rVPT_Maoming rVPT_Meizhou ///
rVPT_Qingyuan rVPT_Shantou rVPT_Shanwei rVPT_Shaoguan rVPT_Yangjiang rVPT_Yunfu rVPT_Zhanjiang rVPT_Zhaoqing rVPT_Zhongshan rVPT_Zhuhai) conv_maxiter(400) from(b_LK 5 b1 3 b45 -2 b_Cost 3)

estat overid


gen AM_J = _b[AM_Margin:_cons]*group_margin + _b[AM_LK:_con]*group_LK + _b[AM1:_cons]*Cater + _b[AM45:_cons]*Wel_Pub

gen AM_R = _b[AMr:VPT_Chaozhou]*Chaozhou + _b[AMr:VPT_Dongguan]*Dongguan + _b[AMr:VPT_Foshan]*Foshan + _b[AMr:VPT_Guangzhou]*Guangzhou ///
+ _b[AMr:VPT_Heyuan]*Heyuan + _b[AMr:VPT_Huizhou]*Huizhou + _b[AMr:VPT_Jiangmen]*Jiangmen + _b[AMr:VPT_Jieyang]*Jieyang ///
+ _b[AMr:VPT_Maoming]*Maoming + _b[AMr:VPT_Meizhou]*Meizhou + _b[AMr:VPT_Qingyuan]*Qingyuan + _b[AMr:VPT_Shantou]*Shantou ///
+ _b[AMr:VPT_Shanwei]*Shanwei  + _b[AMr:VPT_Shaoguan]*Shaoguan + _b[AMr:VPT_Yangjiang]*Yangjiang + _b[AMr:VPT_Yunfu]*Yunfu ///
+ _b[AMr:VPT_Zhanjiang]*Zhanjiang + _b[AMr:VPT_Zhaoqing]*Zhaoqing  + _b[AMr:VPT_Zhongshan]*Zhongshan + _b[AMr:VPT_Zhuhai]*Zhuhai

gen AM = AM_J + AM_R


gen bargain_acquirer = 1/(1+exp(_b[b_LK:_cons]*group_LK +_b[b1:_cons]*Cater + _b[b45:_cons]*Wel_Pub))


predict res, residuals

gen res_adj = res*bargain_acquirer/((1-bargain_acquirer)*_b[b_Cost:_con])

gen cost_adj =_b[b_Cost:_con]*(1+res_adj)/VPT


gen surplus_t = AM - ITFee - cost_adj

gen surplus_m = AM - ITFee - shop_AFee

gen surplus_a = shop_AFee - cost_adj


/***********************
Table 6: Variance decomposition
***********************/

* Group 1
egen SD_AM_1 = sd(AM) if group5==1
gen VAR_AM_1 = SD_AM_1*SD_AM_1

correlate AM_J AM_R if group5==1, cov
gen VAR_AM_J_1 = r(Var_1) if group5==1
gen VAR_AM_R_1 = r(Var_2) if group5==1
gen cov12_1 = r(cov_12) if group5 == 1
correlate AM_J AM_R if group5 == 1
gen corr12_1 = r(rho) if group5 == 1

* LMG
gen VAR_J_LMG_1 = VAR_AM_J_1 + cov12_1 + 0.5*(VAR_AM_R_1-VAR_AM_J_1)*corr12_1*corr12_1
gen VAR_R_LMG_1 = VAR_AM_R_1 + cov12_1 + 0.5*(VAR_AM_J_1-VAR_AM_R_1)*corr12_1*corr12_1

* PMVD
gen VAR_J_PMVD_1 = VAR_AM_J_1 + 2*cov12_1*VAR_AM_J_1/(VAR_AM_J_1+VAR_AM_R_1)
gen VAR_R_PMVD_1 = VAR_AM_R_1 + 2*cov12_1*VAR_AM_R_1/(VAR_AM_J_1+VAR_AM_R_1)


* Group 2
egen SD_AM_2 = sd(AM) if group5==2
gen VAR_AM_2 = SD_AM_2*SD_AM_2

correlate AM_J AM_R if group5==2, cov
gen VAR_AM_J_2 = r(Var_1) if group5==2
gen VAR_AM_R_2 = r(Var_2) if group5==2
gen cov12_2 = r(cov_12) if group5 == 2
correlate AM_J AM_R if group5 == 2
gen corr12_2 = r(rho) if group5 == 2

* LMG
gen VAR_J_LMG_2 = VAR_AM_J_2 + cov12_2 + 0.5*(VAR_AM_R_2-VAR_AM_J_2)*corr12_2*corr12_2
gen VAR_R_LMG_2 = VAR_AM_R_2 + cov12_2 + 0.5*(VAR_AM_J_2-VAR_AM_R_2)*corr12_2*corr12_2

* PMVD
gen VAR_J_PMVD_2 = VAR_AM_J_2 + 2*cov12_2*VAR_AM_J_2/(VAR_AM_J_2+VAR_AM_R_2)
gen VAR_R_PMVD_2 = VAR_AM_R_2 + 2*cov12_2*VAR_AM_R_2/(VAR_AM_J_2+VAR_AM_R_2)


* Group 4
egen SD_AM_4 = sd(AM) if group5==4
gen VAR_AM_4 = SD_AM_4*SD_AM_4

correlate AM_J AM_R if group5==4, cov
gen VAR_AM_J_4 = r(Var_1) if group5==4
gen VAR_AM_R_4 = r(Var_2) if group5==4
gen cov12_4 = r(cov_12) if group5 == 4
correlate AM_J AM_R if group5 == 4
gen corr12_4 = r(rho) if group5 == 4

* LMG
gen VAR_J_LMG_4 = VAR_AM_J_4 + cov12_4 + 0.5*(VAR_AM_R_4-VAR_AM_J_4)*corr12_4*corr12_4
gen VAR_R_LMG_4 = VAR_AM_R_4 + cov12_4 + 0.5*(VAR_AM_J_4-VAR_AM_R_4)*corr12_4*corr12_4

* PMVD
gen VAR_J_PMVD_4 = VAR_AM_J_4 + 2*cov12_4*VAR_AM_J_4/(VAR_AM_J_4+VAR_AM_R_4)
gen VAR_R_PMVD_4 = VAR_AM_R_4 + 2*cov12_4*VAR_AM_R_4/(VAR_AM_J_4+VAR_AM_R_4)


* Group 5
egen SD_AM_5 = sd(AM) if group5==5
gen VAR_AM_5 = SD_AM_5*SD_AM_5

correlate AM_J AM_R if group5==5, cov
gen VAR_AM_J_5 = r(Var_1) if group5==5
gen VAR_AM_R_5 = r(Var_2) if group5==5
gen cov12_5 = r(cov_12) if group5 == 5
correlate AM_J AM_R if group5 == 5
gen corr12_5 = r(rho) if group5 == 5

* LMG
gen VAR_J_LMG_5 = VAR_AM_J_5 + cov12_5 + 0.5*(VAR_AM_R_5-VAR_AM_J_5)*corr12_5*corr12_5
gen VAR_R_LMG_5 = VAR_AM_R_5 + cov12_5 + 0.5*(VAR_AM_J_5-VAR_AM_R_5)*corr12_5*corr12_5

* PMVD
gen VAR_J_PMVD_5 = VAR_AM_J_5 + 2*cov12_5*VAR_AM_J_5/(VAR_AM_J_5+VAR_AM_R_5)
gen VAR_R_PMVD_5 = VAR_AM_R_5 + 2*cov12_5*VAR_AM_R_5/(VAR_AM_J_5+VAR_AM_R_5)


* All Groups
egen SD_AM = sd(AM)
gen VAR_AM = SD_AM*SD_AM

correlate AM_J AM_R, cov
gen VAR_AM_J = r(Var_1)
gen VAR_AM_R = r(Var_2)
gen cov12 = r(cov_12)
correlate AM_J AM_R
gen corr12 = r(rho)

* LMG
gen VAR_J_LMG = VAR_AM_J + cov12 + 0.5*(VAR_AM_R-VAR_AM_J)*corr12*corr12
gen VAR_R_LMG = VAR_AM_R + cov12 + 0.5*(VAR_AM_J-VAR_AM_R)*corr12*corr12

* PMVD
gen VAR_J_PMVD = VAR_AM_J + 2*cov12*VAR_AM_J/(VAR_AM_J+VAR_AM_R)
gen VAR_R_PMVD = VAR_AM_R + 2*cov12*VAR_AM_R/(VAR_AM_J+VAR_AM_R)


su AM VAR_AM_1 VAR_J_LMG_1 VAR_R_LMG_1 VAR_J_PMVD_1 VAR_R_PMVD_1 bargain_acquirer surplus_m surplus_a surplus_t if group5==1 
su AM VAR_AM_2 VAR_J_LMG_2 VAR_R_LMG_2 VAR_J_PMVD_2 VAR_R_PMVD_2 bargain_acquirer surplus_m surplus_a surplus_t if group5==2 
su AM VAR_AM_4 VAR_J_LMG_4 VAR_R_LMG_4 VAR_J_PMVD_4 VAR_R_PMVD_4 bargain_acquirer surplus_m surplus_a surplus_t if group5==4
su AM VAR_AM_5 VAR_J_LMG_5 VAR_R_LMG_5 VAR_J_PMVD_5 VAR_R_PMVD_5 bargain_acquirer surplus_m surplus_a surplus_t if group5==5 
su AM VAR_AM VAR_J_LMG VAR_R_LMG VAR_J_PMVD VAR_R_PMVD bargain_acquirer surplus_m surplus_a surplus_t


/***********************
Table 7: City-level regression
***********************/

sort areacode

reg AM_R WageEmployed_1000 if areacode!=areacode[_n-1]
reg AM_R gdppc_1000 if areacode!=areacode[_n-1]
reg AM_R napopratio if areacode!=areacode[_n-1]

qreg AM_R WageEmployed_1000 if areacode!=areacode[_n-1], q(25)
qreg AM_R gdppc_1000 if areacode!=areacode[_n-1], q(25)
qreg AM_R napopratio if areacode!=areacode[_n-1], q(25)

qreg AM_R WageEmployed_1000 if areacode!=areacode[_n-1], q(75)
qreg AM_R gdppc_1000 if areacode!=areacode[_n-1], q(75)
qreg AM_R napopratio if areacode!=areacode[_n-1], q(75)
